<?php
class Admin_AttributeController
    extends Admin_Abstract
{
    public function viewAction()
    {
        $this->_permision('attribute');
        $this->loadLayout();
        $this->renderLayout();
    }

    public function saveAction()
    {
        $data = $this->getRequest()->getParam('attribute',array());
        $attributeModel = new Model_Eav_Attribute();

        if(!empty($data['id'])) {
            $attributeModel->load($data['id']);
        }

        foreach ($data as $key=>$value) {
            $attributeModel->setData($key,$value);
        }

        try {
            $attributeModel->save();
            $this->_getSession()->addSuccess('Attribute saved');
        } catch (Exception $e) {
            $this->_getSession()->addError($e->getMessage());
        }

        $this->_redirect('admin/attribute/view/');
    }

    public function indexAction()
    {
        $this->_permision('attribute');
        $this->loadLayout();
        $this->renderLayout();
    }
}